<?php

namespace zhtfrontend\models\datas;

use Yii;
use yii\behaviors\TimestampBehavior;
use yii\db\ActiveRecord;
use yii\helpers\ArrayHelper;

/**
 * This is the model class for table "{{%orders_items_relation}}".
 *
 * @property integer $id
 * @property integer $orders_id
 * @property integer $orders_items_id
 * @property integer $lesson
 * @property integer $create_at
 */
class OrdersItemsRelation extends \zhtfrontend\components\bases\BaseModel
{
    /**
     * @inheritdoc
     */
    public static function tableName()
    {
        return '{{%orders_items_relation}}';
    }

    /**
     * @inheritdoc
     */
    public function rules()
    {
        return [
            [['orders_id', 'orders_items_id', 'lesson', 'created_at','customer_id','student_id','goods_id','teach_type','distribution_way','distribution_proportion','subsidy_type','is_scholarship','art_lesson','is_art_scholarship','goods_price_id','is_frequency','deadline'], 'integer'],
            [['lesson_price', 'subsidy_money', 'scholarship','art_lesson_price','art_scholarship'], 'number'],
            [['type','price_name','deadline_type'], 'string'],
        ];
    }

    /**
     * @inheritdoc
     */
    public function attributeLabels()
    {
        return [
            'id' => Yii::t('zhtfrontend', '自增id'),
            'orders_id' => Yii::t('zhtfrontend', '订单 id'),
            'orders_items_id' => Yii::t('zhtfrontend', '订单商品id'),
            'lesson' => Yii::t('zhtfrontend', '转化或者续课课次数'),
            'created_at' => Yii::t('zhtfrontend', '添加时间'),
            'type' => Yii::t('zhtfrontend', '转化/续费'),
            'customer_id' => Yii::t('zhtfrontend', '会员id'),
            'student_id' => Yii::t('zhtfrontend', '学员id'),
            'goods_id' => Yii::t('zhtfrontend', '课程id'),
            'teach_type' => Yii::t('zhtfrontend', '课程类型'),
            'price_name' => Yii::t('zhtfrontend', '价格名称'),
            'lesson_price' => Yii::t('zhtfrontend', '价格'),
            'distribution_way' => Yii::t('zhtfrontend', '分成方式 0 固定 1 比例'),
            'distribution_proportion' => Yii::t('zhtfrontend', '分成金额或比例'),
            'subsidy_type' => Yii::t('zhtfrontend', '课时补贴方式（1，按学生 2 课程）'),
            'subsidy_money' => Yii::t('zhtfrontend', '补贴金额'),
            'is_scholarship' => Yii::t('zhtfrontend', '是否支持奖学金 1 是 2 否'),
            'scholarship' => Yii::t('zhtfrontend', '奖学金'),
            'art_lesson' => Yii::t('zhtfrontend', '艺教学课次'),
            'art_lesson_price' => Yii::t('zhtfrontend', '艺教学课次价格'),
            'is_art_scholarship' => Yii::t('zhtfrontend', '艺教学课次'),
            'art_scholarship' => Yii::t('zhtfrontend', '艺教学价格'),
            'goods_price_id' => Yii::t('zhtfrontend', '价格套餐id'),
            'is_frequency' => Yii::t('zhtfrontend', '是否限制上课次数'),
            'deadline_type' => Yii::t('zhtfrontend', '有效期类型'),
            'deadline' => Yii::t('zhtfrontend', '有效期'),
        ];
    }
    public function behaviors()
    {
        return ArrayHelper::merge(parent::behaviors(), [
            [
                'class' => TimestampBehavior::className(),
                'attributes' => [
                  ActiveRecord::EVENT_BEFORE_INSERT => ['created_at'],
                ],
            ],
        ]);
    }
}
